from django import template
from google.appengine.api import users
from auth.decorators import LOGIN_URL

register = template.Library()

@register.inclusion_tag('auth/titleBar.html')
def titleBar():
    user = users.get_current_user()
    if user:
        return {
            'state': True,
            'email': user.email(),
            'logouturl': users.create_logout_url(LOGIN_URL)
        }
    else:
#        return HttpResponseRedirect(users.create_login_url("/"))
        return {
            'state': False,
            'loginurl': users.create_login_url(LOGIN_URL)
        }
    